package com.future.controller;


import com.future.domain.Result;
import com.future.service.IAnswerSheetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import static com.future.allUtils.constants.PermissionConstants.*;

@RestController
@RequestMapping("/health")
@Api(tags = "健康详情")
public class HealthController {

    @Autowired
    private IAnswerSheetService answerSheetService;

    @GetMapping("/detail/{pageNum}/{pageSize}")
    @ApiOperation("每个学生的历史问卷得分")
    //@PreAuthorize("hasAnyAuthority('"+PSYCHOLOGIST_HEALTH_VIEW+"','"+TEACHER_HEALTH_VIEW+"','"+STUDENT_HEALTH_VIEW+"')")
    public Result getHealthDetail(@PathVariable Integer pageNum,@PathVariable Integer pageSize) {
        return answerSheetService.getMyHistoryScore(pageNum,pageSize);
    }

    @GetMapping("/noted/{pageNum}/{pageSize}")
    @ApiOperation("重点关注学生")
   // @PreAuthorize("hasAnyAuthority('"+PSYCHOLOGIST_HEALTH_VIEW+"','"+TEACHER_HEALTH_VIEW+"')")
    public Result getNotedStudent(@PathVariable("pageNum") Integer pageNum,
                                  @PathVariable("pageSize")Integer pageSize) {
        return answerSheetService.getNoted(pageNum,pageSize);
    }



    @GetMapping("/everyAverage/{pageNum}/{pageSize}")
    @ApiOperation("获取每个问卷的平均分数")
   // @PreAuthorize("hasAnyAuthority('"+PSYCHOLOGIST_HEALTH_VIEW+"','"+TEACHER_HEALTH_VIEW+"')")
    public Result getEveryAverage(@PathVariable Integer pageNum,@PathVariable Integer pageSize) {
        return   answerSheetService.getEveryAverage(pageNum,pageSize);
    }

    @GetMapping("/student/{pageNum}/{pageSize}")
    @ApiOperation("学生健康情况表")
    //@PreAuthorize("hasAnyAuthority('"+PSYCHOLOGIST_HEALTH_VIEW+"','"+TEACHER_HEALTH_VIEW+"')")
    public Result getPage(@PathVariable("pageNum") Integer pageNum,
                          @PathVariable("pageSize") Integer pageSize,
                          @RequestParam(required = false) String realName) {
        return answerSheetService.getHealthTable(pageNum,pageSize,realName);
    }

    @GetMapping("/getS/{pageNum}/{pageSize}")
    @ApiOperation("获取建议")
    public Result getSuggestion(@PathVariable("pageNum") Long pageNum,
                                @PathVariable("pageSize")Long pageSize) {
        return answerSheetService.getSuggestion(pageNum,pageSize);
    }


    @GetMapping("/classStudents")
    @ApiOperation("班级人数：心理医生是获取所有学生的人数")
    //@PreAuthorize("hasAnyAuthority('"+PSYCHOLOGIST_HEALTH_VIEW+"','"+TEACHER_HEALTH_VIEW+"')")
    public Result getClassStudents() {
        return answerSheetService.getClassStudents();
    }

    @GetMapping("/getSingle/{id}")
    @ApiOperation("获取一个问卷的平均分、作答人数等")
   // @PreAuthorize("hasAnyAuthority('"+PSYCHOLOGIST_HEALTH_VIEW+"','"+TEACHER_HEALTH_VIEW+"')")
    public Result getSingle(@PathVariable String id) {
        return answerSheetService.getSingleById(Long.valueOf(id));
    }









}
